Skip to content

Fix Trio imports on Android without interface helpers - #3497

Closed
mikemikimike wants to merge 1 commit into
python-trio:mainfrom
mikemikimike:fix/android-optional-socket-helpers
Closed

Fix Trio imports on Android without interface helpers#3497
mikemikimike wants to merge 1 commit into
python-trio:mainfrom
mikemikimike:fix/android-optional-socket-helpers

Conversation

@mikemikimike

Copy link
Copy Markdown

Summary

Fix Trio imports on Android API levels where CPython does not expose socket.if_indextoname and socket.if_nametoindex.

Changes

Validation

  • PYTHONPATH=src python -m pytest src/trio/_tests/test_socket.py -q — 31 passed, 4 skipped.
  • uv run --with 'ruff>=0.14' ruff check src/trio/socket.py src/trio/_tests/test_socket.py — passed.
  • python -m black --check src/trio/socket.py src/trio/_tests/test_socket.py — passed.
  • uv run --with 'mypy>=1.18' mypy src/trio/socket.py — passed.
  • uv run --with build --with setuptools python -m build --wheel --no-isolation — passed.
  • git diff --check — passed.

The repository's system Ruff 0.15.0 cannot parse the current configuration's newer builtin-argument-shadowing selector, so the compatible Ruff version was supplied through uv. Type checking the whole test module with --follow-imports=skip reports pre-existing test/decorator and ignored-import diagnostics; the changed production module passes mypy.

Compatibility

On platforms that provide these functions, Trio continues to re-export them unchanged. On platforms that do not, importing trio.socket succeeds and the unavailable names are simply absent, consistent with existing platform-specific exports.

Fixes #3493.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (d5eb534) to head (ef7597d).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3497   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19452        19460    +8     
  Branches         1321         1321           
===============================================
+ Hits            19452        19460    +8     
Files with missing lines Coverage Δ
src/trio/_tests/test_socket.py 100.00000% <100.00000%> (ø)
src/trio/socket.py 100.00000% <100.00000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@A5rocks

A5rocks commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Sorry but a) I want to see what CPython will do first and b) don't use LLM generated text for PR descriptions please!

(Also I think the test goes about this the wrong way and the code comment isn't helpful.)

@A5rocks A5rocks closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android API 24 runtime still lacks if_indextoname and if_nametoindex

2 participants